package com.ict.txmsv2.services;

import com.ict.txmsv2.mapper.MenuRoleMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

/**
 * @author yoleen
 * @date 2020/2/28 15:42
 */

@Service
public class MenuRoleService {
    @Autowired
    MenuRoleMapper menuRoleMapper;

    @Transactional
    public boolean updateMenuRoles(Integer rid, Integer[] mids) {
        menuRoleMapper.deleteByRid(rid);
        if (mids==null||mids.length==0){
            return true;
        }
        int res = menuRoleMapper.insertMenuRoles(rid,mids);
        return res == mids.length;
    }
}
